var MWB__MODULE_ID__ = {
	brd : JXG.JSXGraph.initBoard('jxgbox', {
		originX : 250,
		originY : 250,
		unitX : 50,
		unitY : 50,
		axis : true
	}),
	dataSeries : [ { 'x': 0, 'y' : 0 } ],
	plotIt : function() {
		// plot is based on example at http://jsxgraph.uni-bayreuth.de/wiki/index.php/Google_style_chart
		var brd = this.brd;
		var dataSeries = this.dataSeries; 
		var i, x1, y1;
		var p;
		var points = [];
		var x = [];
		var y = [];
		var start = 0;
		var end = dataSeries.length;

		// find the extents of the series
		var xmin = 0, xmax = 0, ymin = 0, ymax = 0;
		for (i = start; i < end; i++) {
			// todo: there's a faster way to do this... the list will be sorted eventually so we know the min is the first element
			if (dataSeries[i].x < xmin) {
				xmin = dataSeries[i].x;
			} else if (dataSeries[i].x > xmax) {
				xmax = dataSeries[i].x;
			}
			if (dataSeries[i].y < ymin) {
				ymin = dataSeries[i].y;
			} else if (dataSeries[i].y > ymax) {
				ymax = dataSeries[i].y;
			}
		}

		points.push(brd.createElement('point', [ xmin, 0 ], {
			visible : false,
			name : '',
			fixed : true
		}));

		for (i = start; i < end; i++) {

			x1 = dataSeries[i].x;
			y1 = dataSeries[i].y;

			// Plot it
			p = brd.createElement('point', [ x1, y1 ], {
				strokeWidth : 2,
				strokeColor : '#ffffff',
				highlightStrokeColor : '#0077cc',
				fillColor : '#0077cc',
				highlightFillColor : '#0077cc',
				style : 6,
				name : '',
				fixed : true
			});
			points.push(p);
			x.push(x1);
			y.push(y1);
		}

		// Filled area. We need two additional points [start,0] and [end,0]
		points.push(brd.createElement('point', [ end, 0 ], {
			visible : false,
			name : '',
			fixed : true
		}));
		brd.createElement('polygon', points, {
			withLines : false,
			fillColor : '#e6f2fa'
		});

		// Curve:
		brd.createElement('curve', [ x, y ], {
			strokeWidth : 3,
			strokeColor : '#0077cc',
			highlightStrokeColor : '#0077cc'
		});
	},

	addPointToList : function(x, y) {
		graphdiv = document.getElementById("jxgbox");
		var typearea = document.createElement("ul");
		typearea.innerHTML = '<li class="point"><span class="nums">' + x + ','
				+ y + '</span></li>';
		graphdiv.appendChild(typearea);
	},

	init : function() {
		// create the data entry form
	graphdiv = document.getElementById("pointlist");
	graphdiv.childNodes[0].data = ""; // remove the "loading" message

	// init the jsx graph area
	var brd = this.brd;
	brd.suspendUpdate();
	this.plotIt();
	brd.unsuspendUpdate();

}
};
MWB__MODULE_ID__.init();